//
//  YAYIRefundOrderCell.m
//  YAYIDoctor
//
//  Created by Veer on 16/9/13.
//
//

#import "YAYIRefundOrderCell.h"

#import "YAYIRefoundOrderModel.h"


@interface YAYIRefundOrderCell()

@property (nonatomic, weak)  UILabel *timeLbl;
@property (nonatomic, weak)  UILabel *recordLbl;
@property (nonatomic, weak)  UIView *lineView;

@end

@implementation YAYIRefundOrderCell

- (void)setModel:(YAYIRefoundOrderModel *)model
{
    _model = model;
    
    self.timeLbl.text = model.timeStr;
    self.recordLbl.text = [NSString stringWithFormat:@"退款%.2f元", model.money / 100.0];
}

+ (instancetype)cellWith:(UITableView *)tablevie
{
    static NSString *cellID = @"refundOrderCell";
    
    YAYIRefundOrderCell *cell = [tablevie dequeueReusableCellWithIdentifier:cellID];
    
    if (nil == cell) {
        cell = [[YAYIRefundOrderCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    return cell;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        [self setupSubView];
    }
    return self;
}


- (void)setupSubView
{
    UILabel *timeLbl = [[UILabel alloc] init];
    timeLbl.font = [UIFont systemFontOfSize:12];
    timeLbl.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:timeLbl];
    self.timeLbl = timeLbl;
    
    UILabel *recordLbl = [[UILabel alloc] init];
    recordLbl.font = [UIFont systemFontOfSize:14];
    recordLbl.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:recordLbl];
    self.recordLbl = recordLbl;
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = YAYICellLineColor;
    [self.contentView addSubview:lineView];
    self.lineView = lineView;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    [self.timeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(10);
    }];
    
    [self.recordLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.bottom.mas_equalTo(-10);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
        make.width.mas_equalTo(SCREEN_width);
    }];
}

@end
